{% extends 'base_backend.html' %}
{% load static %}
{% block header_tail %}
    <link rel="stylesheet" href="{% static 'public/CodeMirror/lib/codemirror.css' %}">
    <link rel="stylesheet" href="{% static 'public/ComboSelect/css/combo.select.css' %}">
    <link rel="stylesheet" href="{% static 'public/CodeMirror/theme/lesser-dark.css' %}">
    <link rel="stylesheet" href="{% static 'public/CodeMirror/addon/dialog/dialog.css' %}">
    <link rel="stylesheet" href="{% static 'public/CodeMirror/addon/search/matchesonscrollbar.css' %}">
    <link rel="stylesheet" href="{% static 'plugins/select2/select2.css' %}">
    <link rel="stylesheet" href="{% static 'public/ComboSelect/css/combo.select.css' %}">
    <link rel="stylesheet" href="{% static 'zhongbao/config/css/main.css' %}">
    <script src="{% static 'plugins\jQuery\jquery-2.2.3.min.js' %}"></script>

    <style>
        .login-banner {
            width: 100%;
            background: url("{% static 'public/img/banner2.jpg' %}") center bottom/cover no-repeat;
        }
    </style>
{% endblock header_tail %}

{% block section_content %}
<div>
        <div class="box-header with-border">
            <h3 class="box-title">{{ model_verbose_name }}</h3>
        </div>
        <!-- form start -->
        <div class="box box-primary">
            <div class="box-body">
                <form id="create_user_form" role="form" action="" method="post"
                      enctype="multipart/form-data"><input type='hidden' name='csrfmiddlewaretoken' value='X4KvkYSWJC04LeLiNhFhvD1WAzJuSkyi' />

                    <div style="width: 60%;height:65px;float: left;">

                            <div class="input-group" style="float: left; padding-right: 20px;width:20%">
                                <label for="" title="">配置ID：</label>
                                <div>
                                    <input class="config-input" value="XXXXX" disabled title="">
                                </div>
                            </div>

                            <div class="input-group" style="float: left; padding-right: 20px;width:20%">
                                <label for="" title="">上传人：</label>
                                <div>
                                    <input class="config-input" value="XXXXX" disabled title="">
                                </div>
                            </div>

                            <div class="input-group" style="float: left; padding-right: 20px;width:20%">
                                <label for="" title="">配置名称：</label>
                                <div>
                                    <input class="config-input" value="psj_sxgp_news.py" disabled title="">
                                </div>
                            </div>

                            <div class="input-group" style="float: left; padding-right: 20px;width:20%">
                                <label for="" title="">上传时间：</label>
                                <div>
                                    <input class="config-input" value="2018-04-02 18:18:43:00" disabled title="">
                                </div>
                            </div>

                            <div class="input-group" style="float: left; padding-right: 20px;width:20%">
                                <label for="" title="启用状态，无法修改分组！若修改，请先取消启用！">所属分组：</label>
                                <div>
                                    <input class="config-input" value="政策网站" disabled title="启用状态，无法修改分组！若修改，请先取消启用！">
                                </div>
                            </div>

                    </div>
                    <div style="width: 12%;height:60px;float: left">
                        <div class="input-group" style="float: left; padding-right: 20px;width: 100%">
                            <label for="" class="control-label">是否启用：</label>
                            <div><p class="config-input" style="float: left; background-color: #ebebe4" disabled>

                                    <span>启用</span>

                            </p></div>
                        </div>
                    </div>
                    <div style="width: 12%;height:60px;float: left">
                        <div class="input-group" style="float: left; padding-right: 20px;width: 100%">
                            <label for="" class="control-label">查看和编辑频道：</label>
                            <div><p class="btn btn-xs btn-primary" id="config-channel" style="float: left">查看和编辑频道
                            </p></div>
                        </div>
                    </div>

                    <div style="clear: both"></div>
                    <div style="width: 100%">


                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">网站名称：</label>
                                    <p class="add-config"><input class="config-input" id="id_webname" maxlength="255" name="webname" placeholder="先上传配置,可自动填写" type="text" value="山西高平" /></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">网站域名：</label>
                                    <p class="add-config"><input class="config-input" id="id_url" maxlength="300" name="url" placeholder="先上传配置,可自动填写" type="text" value="sxgp.gov.cn" /></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">标签：</label>
                                    <p class="add-config"><input class="config-input" id="id_tags" maxlength="200" name="tags" type="text" value="山西高平" /></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">间隔时间：</label>
                                    <p class="add-config"><input class="config-input" id="id_intervaltime" name="intervaltime" type="text" value="0" /></p>
                                </div>




                                    <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                        <label for="" class="control-label">配置重复次数：</label>
                                        <p class="add-config"><input class="config-input" id="id_repeat_times" max="100" min="1" name="repeat_times" type="number" value="1" /></p>
                                    </div>




                                <div class="form-group"
                                     style="float: left; padding-right: 20px;width: 12% ;display:none"
                                >
                                    <label for="" class="control-label">所属分组(可搜索)：</label>
                                    <p class="add-config"><select class="config-input" id="id_gid" name="gid" title="启用状态无法更换分组！">
<option value="">---------</option>
<option value="96" selected="selected">政策网站</option>
</select></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">行业类型：</label>
                                    <p class="add-config"><select class="config-input" id="id_tid" name="tid">
<option value="">---------</option>
<option value="9" selected="selected">政府</option>
</select></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">数据类型：</label>
                                    <p class="add-config"><select class="config-input" id="id_webtype" name="webtype">
<option value="">---------</option>
<option value="15" selected="selected">新闻</option>
</select></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">代理地址：</label>
                                    <p class="add-config"><select class="config-input" id="id_proxy_addresses_id" name="proxy_addresses_id">
<option value="" selected="selected">---------</option>
</select></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">数据来源：</label>
                                    <p class="add-config"><select class="config-input" id="id_datasourcetype" name="datasourcetype">
<option value="0" selected="selected">----</option>
</select></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">入库去重：</label>
                                    <p class="add-config"><select class="config-input" id="id_uig" name="uig">
<option value="" selected="selected">---------</option>
</select></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">日志地址：</label>
                                    <p class="add-config"><select class="config-input" id="id_log_addresses_id" name="log_addresses_id">
<option value="" selected="selected">---------</option>
<option value="1">线上日志</option>
<option value="5">测试日志</option>
</select></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">国家或地区：</label>
                                    <p class="add-config"><select class="config-input" id="id_country" name="country">
<option value="">--------</option>
<option value="CN" selected="selected">中国</option>
</select></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">语言：</label>
                                    <p class="add-config"><select class="config-input" id="id_language" name="language">
<option value="">--------</option>
<option value="zh" selected="selected">中文</option>
</select></p>
                                </div>



                                <div class="form-group" style="float: left; padding-right: 20px;width: 12%">
                                    <label for="" class="control-label">是否代理：</label>
                                    <p class="add-config"><select class="config-input" id="id_is_agent" name="is_agent">
<option value="2" selected="selected">默认</option>
<option value="0">否</option>
<option value="1">是</option>
</select></p>
                                </div>


                    </div>
                    <br style="clear: both">
                    <hr style="margin-top: 0">
                    <div class="form-group">

                            <label for="">修改信息：</label><input type="text" name="change_config_message" size="50"
                                                              placeholder="请填入修改原因和概括修改内容">
                            <span class="btn btn-info btn-xs" tag="1" id="code-eidt">编辑代码</span>


                            <a href="/config/53783/change/history/" class="btn btn-info btn-xs"
                               target="_blank">修改历史</a>

                        <span style="color: #00a7d0;margin-left: 10px"></span>
                    </div>

                    <div class="form-group">
                        <p style="margin-left: 10px; color: #00a7d0;" id="code-help">
                            <span style="font-weight: bold">提示：</span>
                            <span style="margin-right: 10px">修改代码点击<b style="font-weight: bold">编辑代码</b>按钮； </span>
                            <span style="margin-right: 10px">鼠标在代码框内点击后：ctrl+F 查找，ctrl+G 下一个</span>
                        </p>
                        <input id="configId" value="{{ config.id }}" style="display:none;">
                        <div id="file_show">
                            <textarea name="code" id="code" cols="100%" rows="30">{{ config.code }}</textarea>
                        </div>
                    </div>
                        {% if config.status < 4 %}
                            <p class="btn btn-primary" onclick="saveCode()">保存修改</p>
                        {% elif config.status == 6 %}
                            <p class="btn btn-primary" onclick="saveCode()">保存修改</p>
                        {% endif %}
                    <br>

                    <!--确认修改弹出框-->
                    <div class="modal fade" id="cancel-window" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel" style="top:30%">
                        <div class="modal-dialog" role="document">
                            <div class="panel panel-danger">
                                <div class="panel-heading">
                                    <h3 class="panel-title">确认要修改配置吗？</h3>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" id="cancel_close" class="btn btn-default"
                                            data-dismiss="modal">取消
                                    </button>
                                    <button type="submit" id="cancel-submit" class="btn btn-default">
                                        确定
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

                <!-- 频道编辑弹出窗口-->
                <form action="/config/channels/delete/53783/" method="post"><input type='hidden' name='csrfmiddlewaretoken' value='X4KvkYSWJC04LeLiNhFhvD1WAzJuSkyi' />
                    <input type="text" id="channel-change-all" name="channel-change-all" class="no-display"
                           autocomplete="off">
                    <input type="text" id="channel-delete-all" name="channel-delete-all" class="no-display"
                           autocomplete="off">
                    <div class="modal fade" id="config-channel-editor" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel">
                        <div class="modal-dialog modal-lg" role="document" style="width: 80%">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"
                                            id="close-button0"><span
                                            aria-hidden="true">×</span></button>
                                    <h4 class="modal-title" id="myModalLabel">频道修改（必须点击下方-提交-按钮后才能保存修改）</h4>
                                </div>
                                <div class="modal-body" style="width: 100%">
                                    <label for="">修改已添加</label>
                                    <table class="table table-bordered table-striped"
                                           style="width: 100%; table-layout: fixed">
                                        <thead>
                                        <tr>
                                            <th style="width: 75%">频道url</th>
                                            <th style="width: 15%">名称</th>
                                            <th style="width: 10%">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody id="channel-tbody">

                                            <tr class="channel-tr" id="231007">
                                                <td class="channel-url"><span>http://www.sxgp.gov.cn/html/zyh/swsjhd/index.html</span>
                                                    <input type="text" class="no-display"
                                                           value="http://www.sxgp.gov.cn/html/zyh/swsjhd/index.html" style="width: 100%"
                                                           name="channel-url-231007"></td>
                                                <td class="channel-name"><span>市委书记活动</span>
                                                    <input type="text" class="no-display"
                                                           value="市委书记活动"
                                                           name="channel-name-231007">
                                                </td>
                                                <td>
                                                    <span class="btn-link channels-change" style="cursor: pointer"
                                                          tag="1">修改</span>
                                                    |
                                                    <span class="btn-link channels-delete" style="cursor: pointer"
                                                          tag="1">删除</span>
                                                </td>

                                            </tr>

                                            <tr class="channel-tr" id="231006">
                                                <td class="channel-url"><span>http://www.sxgp.gov.cn/html/lydt/index.html</span>
                                                    <input type="text" class="no-display"
                                                           value="http://www.sxgp.gov.cn/html/lydt/index.html" style="width: 100%"
                                                           name="channel-url-231006"></td>
                                                <td class="channel-name"><span>旅游动态</span>
                                                    <input type="text" class="no-display"
                                                           value="旅游动态"
                                                           name="channel-name-231006">
                                                </td>
                                                <td>
                                                    <span class="btn-link channels-change" style="cursor: pointer"
                                                          tag="1">修改</span>
                                                    |
                                                    <span class="btn-link channels-delete" style="cursor: pointer"
                                                          tag="1">删除</span>
                                                </td>

                                            </tr>

                                            <tr class="channel-tr" id="231005">
                                                <td class="channel-url"><span>http://www.sxgp.gov.cn/html/gggs/index.html</span>
                                                    <input type="text" class="no-display"
                                                           value="http://www.sxgp.gov.cn/html/gggs/index.html" style="width: 100%"
                                                           name="channel-url-231005"></td>
                                                <td class="channel-name"><span>人事信息</span>
                                                    <input type="text" class="no-display"
                                                           value="人事信息"
                                                           name="channel-name-231005">
                                                </td>
                                                <td>
                                                    <span class="btn-link channels-change" style="cursor: pointer"
                                                          tag="1">修改</span>
                                                    |
                                                    <span class="btn-link channels-delete" style="cursor: pointer"
                                                          tag="1">删除</span>
                                                </td>

                                            </tr>

                                            <tr class="channel-tr" id="231004">
                                                <td class="channel-url"><span>http://www.sxgp.gov.cn/html/gggs/index.html</span>
                                                    <input type="text" class="no-display"
                                                           value="http://www.sxgp.gov.cn/html/gggs/index.html" style="width: 100%"
                                                           name="channel-url-231004"></td>
                                                <td class="channel-name"><span>公告公示</span>
                                                    <input type="text" class="no-display"
                                                           value="公告公示"
                                                           name="channel-name-231004">
                                                </td>
                                                <td>
                                                    <span class="btn-link channels-change" style="cursor: pointer"
                                                          tag="1">修改</span>
                                                    |
                                                    <span class="btn-link channels-delete" style="cursor: pointer"
                                                          tag="1">删除</span>
                                                </td>

                                            </tr>

                                            <tr class="channel-tr" id="231003">
                                                <td class="channel-url"><span>http://www.sxgp.gov.cn/html/jrgz/index.html</span>
                                                    <input type="text" class="no-display"
                                                           value="http://www.sxgp.gov.cn/html/jrgz/index.html" style="width: 100%"
                                                           name="channel-url-231003"></td>
                                                <td class="channel-name"><span>今日关注</span>
                                                    <input type="text" class="no-display"
                                                           value="今日关注"
                                                           name="channel-name-231003">
                                                </td>
                                                <td>
                                                    <span class="btn-link channels-change" style="cursor: pointer"
                                                          tag="1">修改</span>
                                                    |
                                                    <span class="btn-link channels-delete" style="cursor: pointer"
                                                          tag="1">删除</span>
                                                </td>

                                            </tr>

                                            <tr class="channel-tr" id="231002">
                                                <td class="channel-url"><span>http://www.sxgp.gov.cn/html/zf/index.html</span>
                                                    <input type="text" class="no-display"
                                                           value="http://www.sxgp.gov.cn/html/zf/index.html" style="width: 100%"
                                                           name="channel-url-231002"></td>
                                                <td class="channel-name"><span>政府</span>
                                                    <input type="text" class="no-display"
                                                           value="政府"
                                                           name="channel-name-231002">
                                                </td>
                                                <td>
                                                    <span class="btn-link channels-change" style="cursor: pointer"
                                                          tag="1">修改</span>
                                                    |
                                                    <span class="btn-link channels-delete" style="cursor: pointer"
                                                          tag="1">删除</span>
                                                </td>

                                            </tr>

                                            <tr class="channel-tr" id="231001">
                                                <td class="channel-url"><span>http://www.sxgp.gov.cn/html/rd/index.html</span>
                                                    <input type="text" class="no-display"
                                                           value="http://www.sxgp.gov.cn/html/rd/index.html" style="width: 100%"
                                                           name="channel-url-231001"></td>
                                                <td class="channel-name"><span>人大</span>
                                                    <input type="text" class="no-display"
                                                           value="人大"
                                                           name="channel-name-231001">
                                                </td>
                                                <td>
                                                    <span class="btn-link channels-change" style="cursor: pointer"
                                                          tag="1">修改</span>
                                                    |
                                                    <span class="btn-link channels-delete" style="cursor: pointer"
                                                          tag="1">删除</span>
                                                </td>

                                            </tr>

                                            <tr class="channel-tr" id="231000">
                                                <td class="channel-url"><span>http://www.sxgp.gov.cn/html/sw/index.html</span>
                                                    <input type="text" class="no-display"
                                                           value="http://www.sxgp.gov.cn/html/sw/index.html" style="width: 100%"
                                                           name="channel-url-231000"></td>
                                                <td class="channel-name"><span>市委</span>
                                                    <input type="text" class="no-display"
                                                           value="市委"
                                                           name="channel-name-231000">
                                                </td>
                                                <td>
                                                    <span class="btn-link channels-change" style="cursor: pointer"
                                                          tag="1">修改</span>
                                                    |
                                                    <span class="btn-link channels-delete" style="cursor: pointer"
                                                          tag="1">删除</span>
                                                </td>

                                            </tr>

                                            <tr class="channel-tr" id="230999">
                                                <td class="channel-url"><span>http://www.sxgp.gov.cn/html/jjdt/index.html</span>
                                                    <input type="text" class="no-display"
                                                           value="http://www.sxgp.gov.cn/html/jjdt/index.html" style="width: 100%"
                                                           name="channel-url-230999"></td>
                                                <td class="channel-name"><span>经济动态</span>
                                                    <input type="text" class="no-display"
                                                           value="经济动态"
                                                           name="channel-name-230999">
                                                </td>
                                                <td>
                                                    <span class="btn-link channels-change" style="cursor: pointer"
                                                          tag="1">修改</span>
                                                    |
                                                    <span class="btn-link channels-delete" style="cursor: pointer"
                                                          tag="1">删除</span>
                                                </td>

                                            </tr>

                                        </tbody>
                                    </table>
                                    <div class="form-group" id="channel-display">
                                        <label for="channel-config-content">增加频道-格式:频道URL#频道名称回车</label>
                                        <textarea name="channel-config-content" class="form-control"
                                                  id="channel-config-content"
                                                  cols="30" style="height: 200px;"></textarea>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="submit" id="btn_submit" class="btn btn-primary">
                                        提交
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

            </div>
        </div>
    </div>
    <script>
        function saveCode(){
            var id = $("#configId").val();
            var code = $("#code").val();
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    id: id,
                    code: code
                }
            });
            $.post(
                "{% url 'task:save_code' %}",
                function(response){
                    console.log(response);
                    myVue.message = response.message;
                }
            )
        }
    </script>
{% endblock section_content %}